package com.lhl.booksystem.service.impl;

import com.lhl.booksystem.mapper.BookMapper;
import com.lhl.booksystem.pojo.Book;
import com.lhl.booksystem.pojo.BookType;
import com.lhl.booksystem.pojo.vo.BookVo;
import com.lhl.booksystem.service.BookService;
import jakarta.annotation.Resource;
import org.springframework.stereotype.Service;

import java.util.List;

/**
 * @author LHL
 */
@Service
public class BookServiceImpl implements BookService {
    @Resource
    private BookMapper bookMapper;
    @Override

    public List<BookVo> findBook() {
        return this.bookMapper.findBook();
    }

    @Override
    public boolean save(Book book) {
        if(book.getBid()==null){
            return this.bookMapper.addBook(book)==1;
        }
        return this.bookMapper.updateBook(book)==1;
    }

    @Override
    public boolean del(String arr) {
        String[] ids = arr.split(",");
        return this.bookMapper.delete(ids)>=1;
    }


    @Override
    public List<BookType> findBookType() {
        return this.bookMapper.findBookType();
    }
}
